package com.briup.jz.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.briup.jz.bean.CertificationApply;
import com.briup.jz.bean.extend.CertificationApplyExtend;
import com.briup.jz.service.ICertificationService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/certification")
@Api(description = "实名认证管理接口")
public class CertificationController {
    @Autowired
    private ICertificationService certificationService;

    @ApiOperation(value = "查看认证")
    @GetMapping("findAll")
    public Message findAll() {
        List<CertificationApply> list = certificationService.findAll();
        return MessageUtil.success(list);
    }
    
    @ApiOperation(value = "级联查询所有实名认证申请")
    @GetMapping("queryCascade")
    public Message query(String realName,String status,Long userId ){
        List<CertificationApplyExtend> list = certificationService.queryCascade(realName, status, userId);
        return MessageUtil.success(list);
    }


    @ApiOperation(value = "添加或通过id修改认证")
    @PostMapping("savOrUpdate")
    public Message saveOrEdit(CertificationApply certification) {
    	certificationService.saveOrEdit(certification);
        return MessageUtil.success("保存成功");
    }

    @ApiOperation(value = "通过id删除认证")
    @ApiImplicitParam(name = "id", value = "类别唯一编号", required = true, paramType = "query")
    @GetMapping("deleteById")
    public Message delById(long id) {
    	certificationService.delById(id);
        return MessageUtil.success("删除成功");
    }
}
